var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var protobuf = require("protobufjs/minimal");

var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5
var upload = multer(); // for parsing multipart/form-data

app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded

app.get('/', function(req, res){
    res.send('<h1>Hello world</h1>');
});

app.post('/',  upload.array(), function(req, res) {
    console.log('request body is ' + req.body);
    res.json(req.body);
});

io.on('connection', function(socket){
    console.log('a user connected');
    socket.on('disconnect', function(){
        console.log('user disconnected');
    });
});

http.listen(8000, function(){
    console.log('listening on *:8000');
});
